package org.cloudnote.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.UUID;

public class NoteUtil {

    public static String createId(){
        String uuid = UUID.randomUUID().toString();
        return uuid;
    }

    public static String md5(String string){
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            byte[] input = string.getBytes();
            byte[] output = md5.digest(input);
            return Base64.getEncoder().encodeToString(output);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static void main(String[] args) {
        String s="123";
        System.out.println(md5(s));
    }
}
